package com.dbqn.zhao.service.impl;

import com.dbqn.zhao.entiy.User;
import com.dbqn.zhao.service.CountService;

import java.util.Random;

public class CountServiceImpl implements CountService {

    Random random=new Random();


    @Override
    public User count(User user) {

        if(user.getWeight()>1){
            int money=0;
            for (int i = 1; i < user.getWeight(); i++) {
                money=(int) (user.getGujia()*0.005)+3+(int)(user.getGujia()*0.005);
            }
            user.setBaojia((int) (user.getGujia()*0.005));
            user.setZongjia(money);
            int num1=0;
            String num="";

            for (int i = 0; i <10 ; i++) {

                num1= random.nextInt(9);
                num=num+num1;
            }
            user.setDanh(num);
            return user;
        }else{
            user.setBaojia((int) (user.getGujia()*0.005));
            user.setZongjia((int) (user.getGujia()*0.005));

            return user;
        }

    }

    @Override
    public User data(User user) {

        int num1=0;
        String num="";

        for (int i = 0; i <10 ; i++) {

            num1= random.nextInt(9);
            num=num+num1;
        }
        user.setDanh(num);

        return user;
    }
}
